<?php

defined('SYSPATH') or die('Access error!');
class Core_Log_Syslog extends Log_Writer {

	protected $_ident;

	public function __construct($ident = 'LIUXUDONG', $facility = LOG_USER)
	{
		$this->_ident = $ident;

		openlog($this->_ident, LOG_CONS, $facility);
	}

	public function write(array $messages)
	{
		foreach ($messages as $message)
		{
			if (Log::STRACE == $message['level'])
			{
				$message['level'] = Log::DEBUG;
			}
			syslog($message['level'], $message['body']);
		}
	}

	public function __destruct()
	{
		closelog();
	}

}
